﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Sherwood.Security.Tests
{
    /// <summary>
    /// Tests for PasswordHash functionality
    /// </summary>
    [TestClass]
    public class HashTests
    {
        [TestMethod]
        public void PasswordHashTest()
        {
            //Arrange
            string password = "12345";
            string badPassword = "23454";
            string hash = null;

            //Act
            hash = Hash.ComputeHash(password,"SHA256",null);
            bool passwordValid = Hash.VerifyHash(password,"SHA256",hash);
            bool badPasswordValid = Hash.VerifyHash(badPassword, "SHA256", hash);

            //Assert
            Assert.IsNotNull(hash);
            Assert.IsTrue(passwordValid, "Password should be valid");
            Assert.IsFalse(badPasswordValid, "Invalid password should not be valid");

        }
    }
}
